package com.web;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.LeaveDTO;

import bizlogic.LeaveManager;

/**
 * Servlet implementation class LeaveDelete
 */
@WebServlet("/LeaveDelete")
public class LeaveDelete extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LeaveDelete() {
        super();
      
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}private void doProcess(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("id");
		LeaveManager LM = new LeaveManager();
		LeaveDTO LD = LM.findLeave(username);
		System.out.println(LD.toString());
		LM.deleteLeave(LD);
		
		RequestDispatcher rd = request.getRequestDispatcher("LeaveList");
		rd.forward(request, response);
	}
	
	

}
